import { useState,useEffect } from 'react'
import List from './List'
import axios from 'axios'
 const Loading=()=>{
   return(
     <>
     加载中。。。
     </>
   )
 }
function App() {
const [loading,setLoading]=useState(true)
const [list,setList]=useState([])
useEffect(()=>{
  axios.get('https://www.fastmock.site/mock/2993f6a9e277946ef51c9b947746cd4c/beer/booklist')
  .then(res=>{
 
    if(res.data){
      setList(res.data)
      setLoading(false)
         console.log(res.data);

    }
    else{
      console.log('error');
    }
  })
},[])
  return (
    <div className="App">
      {loading?<Loading></Loading>: <List data={list}></List>}
    
    </div>
  )
}

export default App
